package com.fxd.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @auther fuxudong
 * @date 2021/2/5 - 11:46
 * 拦截器配置步骤：
 *      1，编写拦截器类，实现handlerinterceptor接口
 *      2，配置拦截器类
 */
public class userinterceptor2 implements HandlerInterceptor {


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        System.out.println("preHandle2拦截器预处理");
        return true;
    }


    @Override
    public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) throws Exception {
        System.out.println(modelAndView);
        //request.getRequestDispatcher("/WEB-INF/pages/error.jsp").forward(request,response);
        System.out.println("postHandle2后处理方法执行");

    }


    @Override
    public void afterCompletion(HttpServletRequest request, HttpServletResponse response, Object handler, Exception ex) throws Exception {
        System.out.println("afterCompletion2");

    }
}
